{extend name="public/base"}

{block name="x-body"}
    <div class="x-body">
      <div class="layui-row">
      </div>
      <xblock>
        <button class="layui-btn layui-btn-danger" onclick="delAll('{:url(\'goods/goodsCate_del\')}')"><i class="layui-icon"></i>批量删除</button>
        <button class="layui-btn" onclick="x_admin_show('添加分类','{:url(\'goods/goodsCate_form\')}')"><i class="layui-icon"></i>添加顶级分类</button>
        <span class="x-right" style="line-height:40px">共有数据：{$count} 条</span>
      </xblock>
      <table class="layui-table layui-form">
        <thead>
          <tr>
            <th width="20">
              <div class="layui-unselect header layui-form-checkbox" lay-skin="primary"><i class="layui-icon">&#xe605;</i></div>
            </th>
            <th width="70">ID</th>
            <th>栏目名</th>
            <th width="50">排序</th>
            <th width="60">是否显示</th>
            <th width="240">操作</th>
        </thead>
        <tbody class="x-cate">
          {volist name="list" id="v"}
          <tr cate-id='{$v.id}' fid='{$v.pid}'>
            <td>
              <div class="layui-unselect layui-form-checkbox" lay-skin="primary" data-id='{$v.id}'><i class="layui-icon">&#xe605;</i></div>
            </td>
            <td>{$v.id}</td>
            <td>
              {for start="1" end="$v.level"}
                  &nbsp;&nbsp;&nbsp;&nbsp;
              {/for}
              {if isset($v.max)}
                |-
                {else /}
                <i class="layui-icon x-show" status='true'>&#xe623;</i>
              {/if}
              {if $v.icon}<img src="{:config('imgRoute')}{$v.icon}" alt="" width="30">{/if}
              {$v.cate_name}
            </td>
            <td><input type="text" class="layui-input x-sort" name="sort" data-id="{$v.id}" value="{$v.sort}"></td>
            <td>
              <input type="checkbox" name="switch" data-id="{$v.id}" data-status="{$v.status}" lay-text="是|否" {if $v.status == 1}checked=""{/if} lay-skin="switch">
            </td>
            <td class="td-manage">
              <button class="layui-btn layui-btn layui-btn-xs"  onclick="x_admin_show('编辑商品分类','{:url(\'goods/goodsCate_form\', [\'id\' => $v.id])}')" ><i class="layui-icon">&#xe642;</i>编辑</button>
              <button class="layui-btn layui-btn-warm layui-btn-xs"  onclick="x_admin_show('添加子栏目','{:url(\'goods/goodsCate_form\', [\'id\' => $v.id, \'type\' => \'add\'])}')" ><i class="layui-icon">&#xe642;</i>添加子栏目</button>
              <button class="layui-btn-danger layui-btn layui-btn-xs"  onclick="member_del(this,'{$v.id}', '{:url(\'goods/goodsCate_del\')}')" href="javascript:;" ><i class="layui-icon">&#xe640;</i>删除</button>
            </td>
          </tr>
          {/volist}
        </tbody>
      </table>
    </div>

<script>
  $(document).ready(function (){
    /**
     * 更新排序
     */
    sort('{:url("cateSort")}');

    layui.use('form', function (){
        let form = layui.form;
        /**
         * 更新状态
         */
        editStatus('{:url("goods/cateStatus")}', 'status', form);
    });
  });
</script>
{/block}